package demo;

class OutClass{
    public int date;
    public int data1;
    class InClass{
        //内部类需要外部对象的引用 static是在类加载时候加载的 程序是先加载后运行的
        public static final int data = 100; //加了final之后，data相当于是一个常量，final是常量的意思
        public void test(int date){
            OutClass.this.date = date;//获取外部类的this
        OutClass outClass = new OutClass();
            new OutClass().data1 = date;//实例化一个外部类对象
        }
    }
}


public class Test {
    public static void main(String[] args) {
        //写法1
        OutClass outClass = new OutClass();
        OutClass.InClass inClass = outClass.new InClass();
        inClass.test(100);
        System.out.println(outClass.data1);
        System.out.println(outClass.date);
        //写法2
        OutClass.InClass inClass1 = new OutClass().new InClass();
        inClass1.test(10);
        System.out.println();
    }



}
//OutClass 是外部类
//InClass是是内部类


//内部类可以无限套
class A{
    class B{
        class C{

        }

    }
}
